<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/css/common.min.css">
  <link rel="stylesheet" href="/static/css/app.min.css">
  <style>
    .alter-notice-div{ padding:1rem 1.6rem 1rem 3rem; }
    .alter-notice-div h2{ text-align:center; }
    .alter-notice-div ul li{ font-size:13px;list-style:decimal;margin:0.5rem 0; }
    .agent_level_icon{ width: 125px;height:25px; }
    .agent_level_txt{ width: 100px;height:25px;position:absolute;z-index:2;margin-left:-102px; }
    .agent_level_color{ color: #ff2832; }
  </style>
  <title>资产管理系统</title>
</head>

<body>

  <!-- 程序主入口 -->
  <div id="app">

    <!-- 左侧菜单区 -->
    <div class="layui-side layui-bg-black">
      <!-- 内容 -->
      <div class="layui-side-scroll">
        <!-- 用户信息 -->
        <div class="user-info">
          <div class="icon">
            <img src="{$user.headurl}" onerror="this.src='/static/image/default.jpg'" class="layui-anim layui-anim-scaleSpring layui-circle"
              title="{$user.account}">
          </div>
          <div class="name">
            <span class="mr-5">{$user.name}</span>
            <a href="javascript:void(0)" class="logout-btn">退出</a>
          </div>
          <div class="channel">
            <span>职位:</span>
            <span>{if $user.userRole==UserUtil::ROLE_1}管理员{else}普通账号{/if}</span>
          </div>
        </div>

        <!-- 菜单 -->
        {if $navlist[0]}
        <ul class="layui-nav layui-nav-tree">
          {foreach $navlist[0] as $menuinfo}
          <li class="layui-nav-item {if $menuinfo.selected == '1'}layui-this{/if}">
            <a href="{if $menuinfo.action}{$menuinfo.action}{else}javascript:;{/if}" target="content">{$menuinfo.name}</a>
            {if $navlist[$menuinfo['menuid']]}
            <dl class="layui-nav-child">
              {foreach $navlist[$menuinfo['menuid']] as $chilmenuinfo}
              <dd {if $menuinfo.selected=='1' }class="layui-this" {/if}> <a href="{if $chilmenuinfo.action}{$chilmenuinfo.action}{else}javascript:;{/if}"
                target="content">
                {if $userinfoext.agents == 2 && $chilmenuinfo.name == '支付与提现密码'}
                支付密码
                {else}
                {$chilmenuinfo.name}
                {/if}

                </a>
              </dd>
              {/foreach}
            </dl>
            {/if}
          </li>
          {/foreach}
        </ul>
        {/if}

      </div>


    </div>

    <!-- 右侧内容区 -->
    <div class="app-content">
     <!-- <iframe id="content" name="content" src="	?r=home/list"></iframe>-->
      <iframe id="content" name="content" src=""></iframe>
    </div>

  </div>

  <form class="layui-form" action="" id="set_ad_phone_form" onsubmit="return false" style="margin-top: 30px;margin-right: 30px;display:none;">
    <div class="layui-form-item">
      <label class="layui-form-label"><span class="required" style="color: red;">*</span> 手机号</label>
      <div class="layui-input-block" >
        <input type="text" name="ad_phone" id="ad_phone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
      </div>
    </div>
  </form>

  <script src="/static/layui/layui.js"></script>
  <script src="/static/js/common.js?v=10"></script>
  <script src="/static/js/clipboard.js"></script>
  <script src="/static/js/qrcode.js"></script>
  <script src="/static/js/copy.js"></script>
  <script src="/static/js/app.js?v=1106"></script>
  <script type="text/javascript" src="/static/js/jquery-1.8.3.min.js"></script>
  <script type="text/javascript" src="{$smarty.const.HOST_SITE_RESOURCE}static/js/showDialog.js"></script>
</body>
<script>
    $('#uploadFileBtn').on('click',function(){
      layer.open({
        type: 2,
        title: '上传文件',
        shadeClose: true,
        shade: 0.8,
        area: ['700px', '80%'],
        content: '{$smarty.const.HOST_SITE_RESOURCE}index.php?r=FileUpload/File&appname=suqu' //iframe的url
      });
    });

    $('#setAdPhone').click(function(){
        layer.open({
          type: 1,
          title: '设置手机号'
          ,area: ['450px', '300px']
          ,content: $('#set_ad_phone_form')
          ,btn: ['确定', '取消']
          ,yes:function(index, layero){
            var ad_phone = $('#ad_phone').val();
            if(ad_phone == ''){
              layer.msg('请填写手机号', { icon:2, time:1500, shade:[0.6,'#000',true] });
              return false;
            }
            $.ajax({
              type: "post",
              url: '?r=optimize/setAdPhone',
              data: {
                ad_phone:ad_phone,
              },
              dataType: "json",
              success: function (res) {
                if (res.code == 200) {
                  layer.msg(res.message, { icon: 1, time: 1500, shade: [0.6, '#000', true] }, function () {
                    location.reload();
                  });
                }else{
                  layer.msg(res.message, { icon:2, time:1500, shade:[0.6,'#000',true] });
                }
              },
              error: function () {
                layer.confirm("访问服务器出错", { icon: 2,title:'错误提示',btn : [ '确定'] });
              }
            });
          }
          ,btn2: function(){
            layer.closeAll();
          }
        });
    })

    var linkUrl = "";
    var urlapi = "";
    function changePlatform(host){

      var url = $('#rightPanel').attr('src');

      if (url) {
        var split = url.split("?")
        linkUrl = "?"+split[1];
      }
      console.log(url);
      linkUrl = encodeURIComponent(linkUrl);
      urlapi = host;
      // if (platform == "sq") {
      //   urlapi = '{$smarty.const.SQ_AD_URL}';
      // } else if (platform == "zz") {
      //   urlapi = '{$smarty.const.ZZ_AD_URL}';
      // } else if (platform == "yy") {
      //   urlapi = '{$smarty.const.YY_AD_URL}';
      // }

      $.post(urlapi+"/?r=userlogin/loginByToken", {
        phone: '{$channelExtInfo.login_phone}',
        action: "phone",
        ptoken:'{$channelExtInfo.ptoken}',
      }, function (data) {
        if (data.status == 200) {
          if(data.data.account_list){
            selectAccount(data.data.account_list);
          }else{
            window.location.href = urlapi+"?r=userlogin/loginByToken&phone="+'{$channelExtInfo.login_phone}'+"&action=phone&linkUrl="+linkUrl+"&ptoken="+'{$channelExtInfo.ptoken}';
          }
        } else {
          alert(data.msg);
        }
      }, "json");

    }

    function selectAccount(data){
      var html = '<table class="layui-table" lay-skin="nob"><tbody>';
      for (var i=0; i<data.length; i++){
        html += '<tr><td>'+data[i].channel_name+'</td><td>'+data[i].username+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-normal enter_system" data-adminid="'+data[i].userid+'">进入</button></td></tr>';
      }
      html += '</tr></tbody></table>';
      layui.use(['layer'], function () {
        layer.open({
          type: 1,
          title: '请选择登录账号'
          ,area: ['400px', '300px']
          ,content: html
        });
      });
    }

    $("body").on("click", ".enter_system",function(){
      var adminid = $(this).attr('data-adminid');
      window.location.href = urlapi+"?r=userlogin/loginByToken&phone="+'{$channelExtInfo.login_phone}'+"&action=phone&linkUrl="+linkUrl+"&ptoken="+'{$channelExtInfo.ptoken}'+"&adminid="+adminid;
    });
</script>
</html>